﻿(function ($, undefined) {
    $.fn.gridview = function (options) {
        var defaults = {
            url: "",
            data: {
                pageIndex: 1,
                pageSize: 10
            }
        };
        var opts = $.extend(defaults, options);

        return this.each(function () {
            var obj = $(this);
            reload(obj, opts.data.pageIndex, opts.data.pageSize);
        });
    };
})(jQuery);

function reload(obj, index, size) {
    var data = {
        pageIndex: index,
        pageSize: size
    };

    var url = obj.attr("url");
    
    $.post(url, data, function (content) {
        obj.html(content);
    });
}